package com.study.springcloudgateway.config;

import feign.codec.Decoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.ResponseEntityDecoder;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * @description：
 * @author：李军荣
 * @date: 2020/12/28 17:25
 */
@Configurable
public class FeignConfig {

    @Bean
    public Decoder decoder(){
        return new ResponseEntityDecoder(new SpringDecoder(feignHttpMessageConverter()));
    }


    private ObjectFactory<HttpMessageConverters> feignHttpMessageConverter() {
        HttpMessageConverters converter = new HttpMessageConverters(new MappingJackson2HttpMessageConverter());
        return ()->converter;
    }

}
